package Demo3;

public class TestDemo3 {
    private String userName = "AAAAA";
    private String password = "123456";


    public void login(String userName, String password) {
        try {
            if (!userName.equals(this.userName)) {
                throw new UserNameException("用户名错误！");
            }
            if (!password.equals(this.password)) {
                throw new PasswordException("密码错误！");
            }
            System.out.println("登录成功！");
        } catch (UserNameException e) {
            e.printStackTrace();
        } catch (PasswordException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        TestDemo3 A = new TestDemo3();
        A.login("哈哈","12345");
        A.login("AAAAA","12345");
        A.login("AAAAA","123456");
    }
}
